library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0 ✔ purrr 0.3.5
## ✔ tibble 3.1.8 ✔ dplyr 1.0.10
## ✔ tidyr 1.2.1 ✔ stringr 1.4.1
## ✔ readr 2.1.3 ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(leaflet)
library(dplyr)
library(plotly)
##
## Vedhæfter pakke: 'plotly'
##
## Det følgende objekt er maskeret fra 'package:ggplot2':
##
## last_plot
##
## Det følgende objekt er maskeret fra 'package:stats':
##
## filter
##
## Det følgende objekt er maskeret fra 'package:graphics':
##
## layout
library(ggplot2)
Lynching_data <- read_csv("data/Lynching-Data-Simone-Fixed-xlsx (1).csv")
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
## Rows: 2806 Columns: 36
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (11): State, Day, Victim, County, Race, Sex, Mob, Offense, Note, 2nd Nam...
## dbl (4): Year, Mo, Latitude, Longitude
## lgl (21): Column, Comments, Column2, Column3, Column4, Column5, Column6, Col...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Vis=data.frame(Lynching_data %>%
group_by(Year, Race) %>%
count())
vis_1 <- ggplot(Vis, aes(x=Year,y=n, fill=Race))+
geom_area()+
labs(title = "Killed by race",
y= "Deaths per year",
x= "Year")
ggplotly(vis_1)
vis_1_1 <- ggplot(Vis, aes(x=Year,y=n, fill=Race, color=Race))+
geom_line()+
labs(title = "Killed by race",
y= "Deaths per year",
x= "Year")
ggplotly(vis_1_1)
vis_1_1_1 <- ggplot(Vis, aes(x=Year,y=n, fill=Race, color=Race))+
geom_line()+
labs(title = "Killed by race",
y= "Deaths per year",
x= "Year")+
facet_wrap(~ Race, ncol = 1)
ggplotly(vis_1_1_1)
##This is usefull to show how big the difference was between the race of the people that got lynched. And look at the evolution of people killed through time, but more on that in the final project.
Vis_Offense=data.frame(Lynching_data %>%
group_by(Offense, Race) %>%
count())
library(forcats)
Vis_Offense %>%
ggplot( aes(x=n, y=Offense, fill = Race)) +
geom_bar(stat="identity", fill="#f68060", alpha=.5, width=.7) +
xlab("") +
labs(title = "Offence reasons, all races.",
y= "Reason for lynching",
x= "Number of lynchings")+
theme_bw()
Vis_Offense1=filter(Vis_Offense, Race!='Wht')
Vis_Offense1=filter(Vis_Offense1, Race!='Unk')
Vis_Offense1=filter(Vis_Offense1, Race!='Other')
Vis_Offense1 %>%
ggplot( aes(x=n, y=Offense, fill = Race)) +
geom_bar(stat="identity", fill="#f68060", alpha=.5, width=.7) +
xlab("") +
labs(title = "Offence reasons for black victims.",
y= "Reason for lynching",
x= "Number of lynchings")+
theme_bw()
Vis_Offense2=filter(Vis_Offense, Race!='Blk')
Vis_Offense2=filter(Vis_Offense2, Race!='Unk')
Vis_Offense2=filter(Vis_Offense2, Race!='Other')
Vis_Offense2 %>%
ggplot( aes(x=n, y=Offense, fill = Race)) +
geom_bar(stat="identity", fill="#f68060", alpha=.5, width=.7) +
xlab("") +
labs(title = "Offence reasons for white victims.",
y= "Reason for lynching",
x= "Number of lynchings")+
theme_bw()